/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ihabali
 */
@Entity
@Table(name = "EXAM")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Exam.findAll", query = "SELECT e FROM Exam e"),
    @NamedQuery(name = "Exam.findByExamid", query = "SELECT e FROM Exam e WHERE e.examid = :examid"),
    @NamedQuery(name = "Exam.findByExamdate", query = "SELECT e FROM Exam e WHERE e.examdate = :examdate"),
    @NamedQuery(name = "Exam.findByTitle", query = "SELECT e FROM Exam e WHERE e.title = :title"),
    @NamedQuery(name = "Exam.findByExamdiscription", query = "SELECT e FROM Exam e WHERE e.examdiscription = :examdiscription"),
    @NamedQuery(name = "Exam.findByExamduration", query = "SELECT e FROM Exam e WHERE e.examduration = :examduration")})
public class Exam implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "EXAMID")
    private Integer examid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "EXAMDATE")
    @Temporal(TemporalType.DATE)
    private Date examdate;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "TITLE")
    private String title;
    @Size(max = 2000)
    @Column(name = "EXAMDISCRIPTION")
    private String examdiscription;
    @Size(max = 50)
    @Column(name = "EXAMDURATION")
    private String examduration;
    @JoinTable(name = "JUNCTIONTABLE", joinColumns = {
        @JoinColumn(name = "EXAMID", referencedColumnName = "EXAMID")}, inverseJoinColumns = {
        @JoinColumn(name = "QUESTIONID", referencedColumnName = "QUESTIONID")})
    @ManyToMany
    private List<Questions> questionsList;

    public Exam() {
    }

    public Exam(Integer examid) {
        this.examid = examid;
    }

    public Exam(Integer examid, Date examdate, String title) {
        this.examid = examid;
        this.examdate = examdate;
        this.title = title;
    }

    public Integer getExamid() {
        return examid;
    }

    public void setExamid(Integer examid) {
        this.examid = examid;
    }

    public Date getExamdate() {
        return examdate;
    }

    public void setExamdate(Date examdate) {
        this.examdate = examdate;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getExamdiscription() {
        return examdiscription;
    }

    public void setExamdiscription(String examdiscription) {
        this.examdiscription = examdiscription;
    }

    public String getExamduration() {
        return examduration;
    }

    public void setExamduration(String examduration) {
        this.examduration = examduration;
    }

    @XmlTransient
    public List<Questions> getQuestionsList() {
        return questionsList;
    }

    public void setQuestionsList(List<Questions> questionsList) {
        this.questionsList = questionsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (examid != null ? examid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Exam)) {
            return false;
        }
        Exam other = (Exam) object;
        if ((this.examid == null && other.examid != null) || (this.examid != null && !this.examid.equals(other.examid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.Exam[ examid=" + examid + " ]";
    }
    
}
